<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <style>
      .box {
        display: flex;
        flex-direction: column;
        width: 300px;
        height: 200px;
        border: 1px solid #ccc;
      }
      .box div {
        width: 100%;
        display: flex;
        flex-direction: column;
      }
      .box div input {
        flex: 1;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div>
        请输入用户名<input
          class="username"
          type="text"
          placeholder="请输入用户名"
        />
      </div>
      <div>
        请输入密码<input
          class="userpass"
          type="text"
          placeholder="请输入密码"
        />
      </div>
      <button>点我登录</button>
    </div>
    <script>
      document.querySelector("button").onclick = function () {
        let username = document.querySelector(".box .username").value;
        let userpass = document.querySelector(".box .userpass").value;
        // console.log();
        $.ajax({
          url: "http://127.0.0.1:4000/login",
          method: "post",
          data: {
            username: username,
            password: userpass,
          },
          success: (res) => {
            console.log(res);
          },
        });
      };
    </script>
  </body>
</html>
